<template>
    <div class="categery">
      <div class="categery-item"  v-for="(item,index) in goodslist" :class="{categeryActive:ouccerrindex===index}" @click="itemClick(index)">
        {{item.name}}
      </div>
    </div>
</template>

<script>
  import {getdata} from "../../../network/request";


  export default {
    name: "category",
    data(){
      return{
        goodslist:[],
        ouccerrindex:0,
      }
    },
    created() {
      getdata().then(
          res=>{
            //商品信息
            this.goodslist=res.data.goods;
          }
      )
    },
  methods:{
    itemClick(index){
      this.ouccerrindex=index;
      this.$emit('itemClick',this.ouccerrindex);
    }
  }
  }
</script>

<style scoped>
  .categery{
    width: 100%;
  }
  .categery-item{
    height: 35px;
    text-align: center;
    font-size: 13px;
    background-color: rgba(100,100,100,0.12);
    padding-top: 15px;
    color: #77787b;
  }
  .categeryActive{
    background-color: white;
    color: black;
  }

</style>